
/**
 * 版权所有：上海戈品投资管理有限公司
 *   author king
     功能说明：查询唯一码
     创建日期：2015-11-02
     修改记录：
     备注说明：
 */



$(document).ready(function() {
	//codeList();
});

/**
 * 查询商户列表
 * @returns
 */
var codeList = function(){
	
	var code = $('#code').val();
	var projectName = $('#projectName').val();
	var isGotMoney = $('#isGotMoney').val();
	
	if( ( null == code || code.trim() == '' ) && ( null == projectName || projectName.trim() == '' ) )
	{
		common.showMsg('error', null , '请至少输入手机号或项目名称');
		return;
	}	
	
	var datas = {"p":"merchantManage","m":"queryUniquecode","code":code,"projectName":projectName,"isGotMoney":isGotMoney};//请求参数
	var columnDefine = {"id":"ID","code":"标识","projectName":"项目","createTime":"关注时间","projectId":"项目ID","nickName":"用户","userId":"用户ID"};//表格栏目定义
	var formatters = {//自定义表格格式
			 "isGotMoney": function (column, rowData)
	            {
	   				if(rowData.status=="1")
	   				{
	   					return "<font color=green>已领取</font>";
	   				}
	   				else
	   				{
	   					return "<font color=red>未领取</font>";
	   				}
	            }
	};
	var buttons =''; //操作按钮
		buttons+='<p>';
		buttons+='<button type=\'button\' class=\'btn btn-w-m btn-danger\' onclick="dismiss();">解除绑定</button>&nbsp;&nbsp;';
		buttons+='</p>';
	   hui.pager('service',datas ,"dataList", columnDefine , formatters , buttons ); //分页查询
};

var dismiss = function(){
	var data = $('#pop_win .data').text();
	var json = eval('('+data+')');
	var id = json.id;
	var datas = {"p":"merchantManage","m":"dismissUniquecode","id":id };//请求参数
	json = common.ajaxRequest('service', datas , 'POST');
	if( json&& json.result == 0 )
	{
		codeList();
		$('#pop_win').modal('hide');
		common.showMsg('info', null , '操作成功!');
	}
	else
	{
		common.showMsg('error', null , '操作失败,' + json.message);
	}	
};

var dismissBatch = function(){
	
	var checks= $('#dataList input[name="select"]:checked');
	var ids = '';
	if( checks.length == 0 )
	{
		common.showMsg('error', '', '请先在名单列表中选中要设置状态的人');
		return;
	}
	else
	{
		for(var i=0;i<checks.length;i++)
		{
			if( checks.eq(i).attr("value")!='all')
			{
				ids+=checks.eq(i).attr("value")+",";
			}	
		}
	}
	var datas = {"p":"merchantManage","m":"dismissUniquecode","ids":ids.substring(0,ids.length-1) };//请求参数
	json = common.ajaxRequest('service', datas , 'POST');
	if( json&& json.result == 0 )
	{
		codeList();
		common.showMsg('info', null , '操作成功!');
	}
	else
	{
		common.showMsg('error', null , '操作失败,' + json.message);
	}	
};


